clear
clc
close all

load RTDB_TAB2
A=HICP;nn=size(A,2);

for j=2:nn-23,Y4(j-1)=A(j+1,j+3);end;for j=2:nn-23,Y6(j-1)=A(j+1,j+5);end
for j=2:nn-23,Y8(j-1)=A(j+1,j+7);end;for j=2:nn-23,Y12(j-1)=A(j+1,j+11);end
for j=2:nn-23,Y16(j-1)=A(j+1,j+15);end;for j=2:nn-23,Y24(j-1)=A(j+1,j+23);end

MeCum=[nanmean(-Y24+Y4) nanmean(-Y24+Y6) nanmean(-Y24+Y8)...
    nanmean(-Y24+Y12) nanmean(-Y24+Y16) ];
StdCum=[nanstd(-Y24+Y4) nanstd(-Y24+Y6) nanstd(-Y24+Y8)...
    nanstd(-Y24+Y12) nanstd(-Y24+Y16)  ];
Metot=nanmean(A(:,end));
Stdtot=nanstd(A(:,end));
TAB_agr(:,1)=[Metot; MeCum';Stdtot; StdCum'];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A=PPI;
for j=2:nn-23,Y4(j-1)=A(j+1,j+3);end;for j=2:nn-23,Y6(j-1)=A(j+1,j+5);end
for j=2:nn-23,Y8(j-1)=A(j+1,j+7);end;for j=2:nn-23,Y12(j-1)=A(j+1,j+11);end
for j=2:nn-23,Y16(j-1)=A(j+1,j+15);end;for j=2:nn-23,Y24(j-1)=A(j+1,j+23);end

MeCum=[nanmean(-Y24+Y4) nanmean(-Y24+Y6) nanmean(-Y24+Y8)...
    nanmean(-Y24+Y12) nanmean(-Y24+Y16) ];
StdCum=[nanstd(-Y24+Y4) nanstd(-Y24+Y6) nanstd(-Y24+Y8)...
    nanstd(-Y24+Y12) nanstd(-Y24+Y16)  ];
Metot=nanmean(A(:,end));
Stdtot=nanstd(A(:,end));
TAB_agr(:,2)=[Metot; MeCum';Stdtot; StdCum'];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A=HLC;
for j=2:27
    Y4(j-1)=A(j+1,(j-1)*2+j+3);Y6(j-1)=A(j+1,(j-1)*2+j+5);Y8(j-1)=A(j+1,(j-1)*2+j+7);
    Y12(j-1)=A(j+1,(j-1)*2+j+11);Y16(j-1)=A(j+1,(j-1)*2+j+15);Y24(j-1)=A(j+1,(j-1)*2+j+23);
end

MeCum=[nanmean(-Y24+Y4) nanmean(-Y24+Y6) nanmean(-Y24+Y8)...
    nanmean(-Y24+Y12) nanmean(-Y24+Y16) ];
StdCum=[nanstd(-Y24+Y4) nanstd(-Y24+Y6) nanstd(-Y24+Y8)...
    nanstd(-Y24+Y12) nanstd(-Y24+Y16)  ];
Metot=nanmean(A(:,end));
Stdtot=nanstd(A(:,end));
TAB_agr(:,3)=[Metot; MeCum';Stdtot; StdCum'];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A=DEF;
for j=2:27
    Y4(j-1)=A(j+1,(j-1)*2+j+3);Y6(j-1)=A(j+1,(j-1)*2+j+5);Y8(j-1)=A(j+1,(j-1)*2+j+7);
    Y12(j-1)=A(j+1,(j-1)*2+j+11);Y16(j-1)=A(j+1,(j-1)*2+j+15);Y24(j-1)=A(j+1,(j-1)*2+j+23);
end

MeCum=[nanmean(-Y24+Y4) nanmean(-Y24+Y6) nanmean(-Y24+Y8)...
    nanmean(-Y24+Y12) nanmean(-Y24+Y16) ];
StdCum=[nanstd(-Y24+Y4) nanstd(-Y24+Y6) nanstd(-Y24+Y8)...
    nanstd(-Y24+Y12) nanstd(-Y24+Y16)  ];
Metot=nanmean(A(:,end));
Stdtot=nanstd(A(:,end));
TAB_agr(:,4)=[Metot; MeCum';Stdtot; StdCum'];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A=M3;
for j=2:nn-23,Y4(j-1)=A(j+1,j+3);end;for j=2:nn-23,Y6(j-1)=A(j+1,j+5);end
for j=2:nn-23,Y8(j-1)=A(j+1,j+7);end;for j=2:nn-23,Y12(j-1)=A(j+1,j+11);end
for j=2:nn-23,Y16(j-1)=A(j+1,j+15);end;for j=2:nn-23,Y24(j-1)=A(j+1,j+23);end

MeCum=[nanmean(-Y24+Y4) nanmean(-Y24+Y6) nanmean(-Y24+Y8)...
    nanmean(-Y24+Y12) nanmean(-Y24+Y16) ];
StdCum=[nanstd(-Y24+Y4) nanstd(-Y24+Y6) nanstd(-Y24+Y8)...
    nanstd(-Y24+Y12) nanstd(-Y24+Y16)  ];
Metot=nanmean(A(:,end));
Stdtot=nanstd(A(:,end));
TAB_agr(:,5)=[Metot; MeCum';Stdtot; StdCum'];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A=GDP;
for j=2:27
    Y4(j-1)=A(j+1,(j-1)*2+j+3);Y6(j-1)=A(j+1,(j-1)*2+j+5);Y8(j-1)=A(j+1,(j-1)*2+j+7);
    Y12(j-1)=A(j+1,(j-1)*2+j+11);Y16(j-1)=A(j+1,(j-1)*2+j+15);Y24(j-1)=A(j+1,(j-1)*2+j+23);
end

MeCum=[nanmean(-Y24+Y4) nanmean(-Y24+Y6) nanmean(-Y24+Y8)...
    nanmean(-Y24+Y12) nanmean(-Y24+Y16) ];
StdCum=[nanstd(-Y24+Y4) nanstd(-Y24+Y6) nanstd(-Y24+Y8)...
    nanstd(-Y24+Y12) nanstd(-Y24+Y16)  ];
Metot=nanmean(A(:,end));
Stdtot=nanstd(A(:,end));
TAB_agr(:,6)=[Metot; MeCum';Stdtot; StdCum'];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A=IP;
for j=2:nn-23,Y4(j-1)=A(j+1,j+3);end;for j=2:nn-23,Y6(j-1)=A(j+1,j+5);end
for j=2:nn-23,Y8(j-1)=A(j+1,j+7);end;for j=2:nn-23,Y12(j-1)=A(j+1,j+11);end
for j=2:nn-23,Y16(j-1)=A(j+1,j+15);end;for j=2:nn-23,Y24(j-1)=A(j+1,j+23);end

MeCum=[nanmean(-Y24+Y4) nanmean(-Y24+Y6) nanmean(-Y24+Y8)...
    nanmean(-Y24+Y12) nanmean(-Y24+Y16) ];
StdCum=[nanstd(-Y24+Y4) nanstd(-Y24+Y6) nanstd(-Y24+Y8)...
    nanstd(-Y24+Y12) nanstd(-Y24+Y16)  ];
Metot=nanmean(A(:,end));
Stdtot=nanstd(A(:,end));
TAB_agr(:,7)=[Metot; MeCum';Stdtot; StdCum'];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A=ESI;
for j=2:nn-23,Y4(j-1)=A(j+1,j+3);end;for j=2:nn-23,Y6(j-1)=A(j+1,j+5);end
for j=2:nn-23,Y8(j-1)=A(j+1,j+7);end;for j=2:nn-23,Y12(j-1)=A(j+1,j+11);end
for j=2:nn-23,Y16(j-1)=A(j+1,j+15);end;for j=2:nn-23,Y24(j-1)=A(j+1,j+23);end

MeCum=[nanmean(-Y24+Y4) nanmean(-Y24+Y6) nanmean(-Y24+Y8)...
    nanmean(-Y24+Y12) nanmean(-Y24+Y16) ];
StdCum=[nanstd(-Y24+Y4) nanstd(-Y24+Y6) nanstd(-Y24+Y8)...
    nanstd(-Y24+Y12) nanstd(-Y24+Y16)  ];
Metot=nanmean(A(:,end));
Stdtot=nanstd(A(:,end));
TAB_agr(:,8)=[Metot; MeCum';Stdtot; StdCum'];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A=CU;
for j=2:27
    Y4(j-1)=A(j+1,(j-1)*2+j+3);Y6(j-1)=A(j+1,(j-1)*2+j+5);Y8(j-1)=A(j+1,(j-1)*2+j+7);
    Y12(j-1)=A(j+1,(j-1)*2+j+11);Y16(j-1)=A(j+1,(j-1)*2+j+15);Y24(j-1)=A(j+1,(j-1)*2+j+23);
end

MeCum=[nanmean(-Y24+Y4) nanmean(-Y24+Y6) nanmean(-Y24+Y8)...
    nanmean(-Y24+Y12) nanmean(-Y24+Y16) ];
StdCum=[nanstd(-Y24+Y4) nanstd(-Y24+Y6) nanstd(-Y24+Y8)...
    nanstd(-Y24+Y12) nanstd(-Y24+Y16)  ];
Metot=nanmean(A(:,end));
Stdtot=nanstd(A(:,end));
TAB_agr(:,9)=[Metot; MeCum';Stdtot; StdCum'];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A=EMP;
for j=2:27
    Y4(j-1)=A(j+1,(j-1)*2+j+3);Y6(j-1)=A(j+1,(j-1)*2+j+5);Y8(j-1)=A(j+1,(j-1)*2+j+7);
    Y12(j-1)=A(j+1,(j-1)*2+j+11);Y16(j-1)=A(j+1,(j-1)*2+j+15);Y24(j-1)=A(j+1,(j-1)*2+j+23);
end

MeCum=[nanmean(-Y24+Y4) nanmean(-Y24+Y6) nanmean(-Y24+Y8)...
    nanmean(-Y24+Y12) nanmean(-Y24+Y16) ];
StdCum=[nanstd(-Y24+Y4) nanstd(-Y24+Y6) nanstd(-Y24+Y8)...
    nanstd(-Y24+Y12) nanstd(-Y24+Y16)  ];
Metot=nanmean(A(:,end));
Stdtot=nanstd(A(:,end));
TAB_agr(:,10)=[Metot; MeCum';Stdtot; StdCum'];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A=UR;
for j=2:nn-23,Y4(j-1)=A(j+1,j+3);end;for j=2:nn-23,Y6(j-1)=A(j+1,j+5);end
for j=2:nn-23,Y8(j-1)=A(j+1,j+7);end;for j=2:nn-23,Y12(j-1)=A(j+1,j+11);end
for j=2:nn-23,Y16(j-1)=A(j+1,j+15);end;for j=2:nn-23,Y24(j-1)=A(j+1,j+23);end

MeCum=[nanmean(-Y24+Y4) nanmean(-Y24+Y6) nanmean(-Y24+Y8)...
    nanmean(-Y24+Y12) nanmean(-Y24+Y16) ];
StdCum=[nanstd(-Y24+Y4) nanstd(-Y24+Y6) nanstd(-Y24+Y8)...
    nanstd(-Y24+Y12) nanstd(-Y24+Y16)  ];
Metot=nanmean(A(:,end));
Stdtot=nanstd(A(:,end));
TAB_agr(:,11)=[Metot; MeCum';Stdtot; StdCum'];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

TAB_agr=round(TAB_agr*100)/100;

disp(' ')
disp('--------------------------------------------------------------------------------------------------------------------')

disp('                      HICP      PPI     HLC      DEF       M3      RGDP      IP       ESI      CU      EMP       UR')
disp(['Mean','                   ', num2str(TAB_agr(1,:),2)])
disp('Mean of revisions')
disp(['Y_{t|t+4}-Y_{t|t+24}','   ', num2str(TAB_agr(2,:),2)])
disp(['Y_{t|t+6}-Y_{t|t+24}','   ', num2str(TAB_agr(3,:),2)])
disp(['Y_{t|t+8}-Y_{t|t+24}','   ', num2str(TAB_agr(4,:),2)])
disp(['Y_{t|t+12}-Y_{t|t+24}','  ', num2str(TAB_agr(5,:),2)])
disp(['Y_{t|t+16}-Y_{t|t+24}','  ', num2str(TAB_agr(6,:),2)])
disp(['Standard deviation','     ', num2str(TAB_agr(7,:),2)])
disp('Standard deviation of revisions')
disp(['Y_{t|t+4}-Y_{t|t+24}','    ', num2str(TAB_agr(8,:),2)])
disp(['Y_{t|t+6}-Y_{t|t+24}','   ', num2str(TAB_agr(9,:),2)])
disp(['Y_{t|t+8}-Y_{t|t+24}','   ', num2str(TAB_agr(10,:),2)])
disp(['Y_{t|t+12}-Y_{t|t+24}','  ', num2str(TAB_agr(11,:),2)])
disp(['Y_{t|t+16}-Y_{t|t+24}','  ', num2str(TAB_agr(12,:),2)])




     